﻿<UserControl x:Class="ScrumFactory.ProjectTeam.RolesList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:props="clr-namespace:ScrumFactory.ProjectTeam.Properties"
             
             xmlns:SF_Helpers="clr-namespace:ScrumFactory.Windows.Helpers;assembly=ScrumFactory.Windows.Helpers"
             
             x:Name="thisView"
             mc:Ignorable="d" 
             
             
             d:DesignHeight="300" d:DesignWidth="600">
    <Grid                      
            Margin="10,0,5,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0">
            <TextBlock Margin="0,10,0,0" Style="{StaticResource PanelMainTitle}" Text="{Binding PanelName}"/>
        </StackPanel>



        <Border Grid.Row="1"
                        Style="{StaticResource ContentPanelBorder}"
                        Margin="0,5,0,0"
                        HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

            <Grid VerticalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <ToolBar                                        
                    Grid.Row="0">
                    <MenuItem                                
                        Header="{x:Static props:Resources.Add_new_role}" Command="{Binding AddNewRoleCommand}">
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/add.png" Width="32" Height="32" Stretch="Uniform"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem                                
                        Header="{x:Static props:Resources.Close}"                        
                        Command="{Binding CloseWindowCommand}" CommandParameter="{Binding ElementName=thisView}">
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/Close_window.png" Width="32" Height="32" Stretch="Uniform"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    
                </ToolBar>
                
                <Grid Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />                     
                    </Grid.ColumnDefinitions>

                    <ListBox
                        x:Name="list"
                        Grid.Column="0"                
                        Width="250"
                        IsSynchronizedWithCurrentItem="True"
                        Background="Transparent"
                        BorderThickness="0"
                        SelectedItem="{Binding SelectedRole}"
                        ItemContainerStyle="{StaticResource HorizontalLineDividedListBoxItem}"                      
                        ItemsSource="{Binding Roles}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>                                
                                <StackPanel Orientation="Horizontal" x:Name="panel">
                                    <Image Source="/Images/Toolbar/teamMember.png" VerticalAlignment="Top" Stretch="Uniform" Width="24" Height="24" Margin="5"/>
                                        <StackPanel Orientation="Vertical">
                                            <TextBlock >
                                        <TextBlock
                                        FontSize="{StaticResource BigFontSize}" Foreground="{StaticResource TitleTextBrush}"
                                            TextWrapping="Wrap"
                                        Text="{Binding Role.RoleName}"/>                                        
                                        <LineBreak/>
                                        <TextBlock
                                            Width="200" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" MaxHeight="60"
                                        FontSize="{StaticResource SmallFontSize}" Foreground="{StaticResource SubTextBrush}"
                                            Text="{Binding Role.RoleDescription}"/>                                        
                                    </TextBlock>
                                        <Button
                                            x:Name="removeButton"
                                            Style="{StaticResource RemoveButton}"
                                            Opacity="0"
                                            DockPanel.Dock="Right" HorizontalAlignment="Right"                                                                                        
                                            Command="{Binding ElementName=list, Path=DataContext.DeleteRoleCommand}"
                                            CommandParameter="{Binding}"/>
                                            
                                        <StackPanel.Triggers>
                                            <EventTrigger RoutedEvent="DockPanel.MouseEnter">
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <DoubleAnimation
                                                        Storyboard.TargetName="removeButton" 
                                                        Storyboard.TargetProperty="Opacity"
                                                        From="0" To="1" Duration="00:00:01" 
                                                        FillBehavior="HoldEnd" />
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </EventTrigger>
                                            <EventTrigger RoutedEvent="DockPanel.MouseLeave">
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <DoubleAnimation
                                                        Storyboard.TargetName="removeButton" 
                                                        Storyboard.TargetProperty="Opacity"
                                                        From="1" To="0" Duration="0" 
                                                        FillBehavior="HoldEnd" />
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </EventTrigger>
                                        </StackPanel.Triggers>
                                    </StackPanel>
                                    
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    
                    <Grid Grid.Column="1" DataContext="{Binding ElementName=list, Path=SelectedItem}" Margin="10,0,0,0" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <TextBlock 
                            Grid.Column="0" Grid.Row="0"
                            VerticalAlignment="Top"
                            Style="{StaticResource LabelTextBlock}"
                            Text="{x:Static props:Resources.Role_name}"/>
                        <TextBox
                            Grid.Column="1" Grid.Row="0"                        
                            HorizontalAlignment="Stretch" MaxLength="50"
                            Text="{Binding Role.RoleName, UpdateSourceTrigger=PropertyChanged}"/>
                        <TextBlock 
                            Grid.Column="0" Grid.Row="1"
                            VerticalAlignment="Top"
                            Style="{StaticResource LabelTextBlock}"
                            Text="{x:Static props:Resources.Description}"/>
                        <TextBox
                            Grid.Column="1" Grid.Row="1"                        
                            HorizontalAlignment="Stretch" Height="100" MaxLength="255"
                            ScrollViewer.VerticalScrollBarVisibility="Auto"
                            TextWrapping="Wrap"                            
                            Text="{Binding Role.RoleDescription, UpdateSourceTrigger=PropertyChanged}"/>

                    </Grid>
                    
                    
                    
                </Grid>
                
            </Grid>

        </Border>

    </Grid>
</UserControl>
